/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 阿宾
 * Date: 2024-11-20
 * Time: 09:24
 */
public class MyBinaryTreeTest {
    public static void main(String[] args) {
        MyBinaryTree myBinaryTree = new MyBinaryTree();
        //创建树
        /*
                     A
                  /    \
                B       C
               / \     /  \
              D   E   F   G
                  \
                   H
         */
        MyBinaryTree.TreeNode tree = myBinaryTree.createTree();

        //前序遍历
        myBinaryTree.preOrder(tree);
        System.out.println();
        //中序遍历
        myBinaryTree.inOrder(tree);
        System.out.println();
        //后序遍历
        myBinaryTree.postOrder(tree);
        System.out.println();

        /*List<MyBinaryTree.TreeNode> list= myBinaryTree.preOrder2(tree);
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i).val + " ");
        }
        System.out.println();
        List<MyBinaryTree.TreeNode> list1= myBinaryTree.inOrder2(tree);
        for (int i = 0; i < list1.size(); i++) {
            System.out.print(list1.get(i).val + " ");
        }
        System.out.println();
        List<MyBinaryTree.TreeNode> list2= myBinaryTree.postOrder2(tree);
        for (int i = 0; i < list2.size(); i++) {
            System.out.print(list2.get(i).val + " ");
        }*/

        /*//打印二叉树的节点数
        System.out.println(myBinaryTree.size1(tree));
        myBinaryTree.size(tree);
        System.out.println("二叉树的节点个数："+ myBinaryTree.nodeCount);
        //打印叶子节点个数
        System.out.println(myBinaryTree.getLeafNodeCount(tree));
        myBinaryTree.getLeafNodeCount1(tree);
        System.out.println("叶子结点个数：" + myBinaryTree.leafCount);

        //获取第K层节点个数
        System.out.println(myBinaryTree.getKLevelNodeCount(tree, 2));
        System.out.println(myBinaryTree.getKLevelNodeCount(tree, 3));
        System.out.println(myBinaryTree.getKLevelNodeCount(tree, 4));
        myBinaryTree.getKLevelNodeCount1(tree,3,1);
        System.out.println("第3层节点个数："+ myBinaryTree.levalCount);

        //获取二叉树的高度
        System.out.println(myBinaryTree.getHeight(tree));
        myBinaryTree.getHeight1(tree,1);
        System.out.println(myBinaryTree.height);

        boolean ret = myBinaryTree.find(tree, 'k');
        System.out.println(ret);*/
        //层序遍历
        myBinaryTree.levelOrder(tree);
    }
}
